#include "yocto/utest/run.hpp"
#include "kernel/initializer.hpp"

#include "yocto/ios/ocstream.hpp"
#include "yocto/lua/lua-state.hpp"
#include "yocto/lua/lua-config.hpp"
#include "yocto/code/rand.hpp"

using namespace yocto;


YOCTO_UNIT_TEST_IMPL(init)
{
	_rand.wseed();
	
	if( argc <= 1 )
		throw exception("%s: need script.lua", argv[0] );
	Library     lib;
	ChemSys     chs(lib);
	Initializer ini(lib);
	
	Lua::State VM;
	lua_State *L = VM();
	Lua::Config::DoFile( L, argv[1] );
	lib.load(L,"library");
	
	chs.load(L,"chemsys");
	chs.compile();
	
	ini.load(L,"init_in");
	ini.compile();
	
	std::cerr << "Finding Initial Conditions of ChemSys" << std::endl;
	ini.setup( chs, 0);
	std::cerr << "Checking Law of Mass Action" << std::endl;
	chs.solveGamma(0);
	
	
}
YOCTO_UNIT_TEST_DONE()
